home *** CD-ROM | disk | FTP | other *** search
- package com.sun.java.swing;
-
- import com.sun.java.swing.border.Border;
- import com.sun.java.swing.plaf.ComponentUI;
- import java.awt.Color;
- import java.awt.Font;
- import java.beans.PropertyChangeListener;
- import java.beans.PropertyChangeSupport;
- import java.lang.reflect.Method;
- import java.util.Hashtable;
-
- public class UIDefaults extends Hashtable {
- private static final Object PENDING = new String("Pending");
- private PropertyChangeSupport changeSupport;
- static Class class$com$sun$java$swing$JComponent;
-
- public UIDefaults() {
- }
-
- public UIDefaults(Object[] keyValueList) {
- super(keyValueList.length / 2);
-
- for(int i = 0; i < keyValueList.length; i += 2) {
- super.put(keyValueList[i], keyValueList[i + 1]);
- }
-
- }
-
- public synchronized void addPropertyChangeListener(PropertyChangeListener listener) {
- if (this.changeSupport == null) {
- this.changeSupport = new PropertyChangeSupport(this);
- }
-
- this.changeSupport.addPropertyChangeListener(listener);
- }
-
- protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
- if (this.changeSupport != null) {
- this.changeSupport.firePropertyChange(propertyName, oldValue, newValue);
- }
-
- }
-
- public Object get(Object key) {
- Object value = super.get(key);
- if (value != PENDING && !(value instanceof ActiveValue) && !(value instanceof LazyValue)) {
- return value;
- } else {
- synchronized(this) {
- value = super.get(key);
- if (value == PENDING) {
- do {
- try {
- this.wait();
- } catch (InterruptedException var22) {
- }
-
- value = super.get(key);
- } while(value == PENDING);
-
- return value;
- }
-
- if (value instanceof LazyValue) {
- super.put(key, PENDING);
- } else if (!(value instanceof ActiveValue)) {
- return value;
- }
- }
-
- if (value instanceof LazyValue) {
- try {
- value = ((LazyValue)value).createValue(this);
- } finally {
- synchronized(this){}
-
- try {
- if (value == null) {
- super.remove(key);
- } else {
- super.put(key, value);
- }
-
- this.notify();
- } catch (Throwable var21) {
- throw var21;
- }
-
- }
- } else {
- value = ((ActiveValue)value).createValue(this);
- }
-
- return value;
- }
- }
-
- public Border getBorder(Object key) {
- Object value = this.get(key);
- return value instanceof Border ? (Border)value : null;
- }
-
- public Color getColor(Object key) {
- Object value = this.get(key);
- return value instanceof Color ? (Color)value : null;
- }
-
- public Font getFont(Object key) {
- Object value = this.get(key);
- return value instanceof Font ? (Font)value : null;
- }
-
- public Icon getIcon(Object key) {
- Object value = this.get(key);
- return value instanceof Icon ? (Icon)value : null;
- }
-
- public String getString(Object key) {
- Object value = this.get(key);
- return value instanceof String ? (String)value : null;
- }
-
- public ComponentUI getUI(JComponent target) {
- Class uiClass = this.getUIClass(target.getUIClassID());
- Object uiObject = null;
- if (uiClass == null) {
- this.getUIError("no ComponentUI class for: " + target);
- } else {
- try {
- Class var10000 = class$com$sun$java$swing$JComponent;
- if (var10000 == null) {
- try {
- var10000 = Class.forName("com.sun.java.swing.JComponent");
- } catch (ClassNotFoundException var6) {
- throw new NoClassDefFoundError(((Throwable)var6).getMessage());
- }
-
- class$com$sun$java$swing$JComponent = var10000;
- }
-
- Class acClass = var10000;
- Method m = uiClass.getMethod("createUI", acClass);
- uiObject = m.invoke((Object)null, target);
- } catch (NoSuchMethodException var7) {
- this.getUIError("static createUI() method not found in " + uiClass);
- } catch (Exception var8) {
- this.getUIError("createUI() failed for " + target + " " + var8);
- }
- }
-
- return (ComponentUI)uiObject;
- }
-
- public Class getUIClass(String uiClassID) {
- Object className = this.get(uiClassID);
-
- try {
- return className instanceof String ? Class.forName((String)className) : null;
- } catch (ClassNotFoundException var3) {
- return null;
- }
- }
-
- protected void getUIError(String msg) {
- System.err.println("UIDefaults.getUI() failed: " + msg);
-
- try {
- throw new Error();
- } catch (Throwable var3) {
- var3.printStackTrace();
- }
- }
-
- public Object put(Object key, Object value) {
- Object oldValue = value == null ? super.remove(key) : super.put(key, value);
- if (key instanceof String) {
- this.firePropertyChange((String)key, oldValue, value);
- }
-
- return oldValue;
- }
-
- public void putDefaults(Object[] keyValueList) {
- for(int i = 0; i < keyValueList.length; i += 2) {
- Object value = keyValueList[i + 1];
- if (value == null) {
- super.remove(keyValueList[i]);
- } else {
- super.put(keyValueList[i], value);
- }
- }
-
- this.firePropertyChange("UIDefaults", (Object)null, (Object)null);
- }
-
- public synchronized void removePropertyChangeListener(PropertyChangeListener listener) {
- if (this.changeSupport != null) {
- this.changeSupport.removePropertyChangeListener(listener);
- }
-
- }
- }
-